#include "stdafx.h"
#include "javascript.h"
#include "jwindow.h"

#ifdef _DEBUG
#define new DEBUG_NEW
#endif

namespace gtl
{

namespace skins
{

javascript::javascript()
{
}

javascript::~javascript()
{
}

void javascript::init()
{
	v8::HandleScope handle_scope;

	m_global = v8::ObjectTemplate::New();
	m_global->Set(v8::String::New("print"), v8::FunctionTemplate::New(jscript::print));

	CProxyV8::ProxyClass<jwindow>* proxy = CProxyV8::ProxyClass<jwindow>::instance()->init("jwindow");
	proxy->Expose(&jwindow::show, "show");
	proxy->Expose(&jwindow::close, "close");
	proxy->Expose(&jwindow::move, "move");
	proxy->Expose(&jwindow::visible, "visible");
	proxy->Expose(&jwindow::alert, "alert");
	proxy->Expose(&jwindow::hwnd, "hwnd");
	proxy->Expose(&jwindow::rect, "rect");
	proxy->Expose(&jwindow::width, "width");
	proxy->Expose(&jwindow::height, "height");
	proxy->Expose(&jwindow::position, "position");
	m_global->Set(v8::String::New("__internal_jwindow__"), proxy->GetFunctionTemplate());

	m_context = v8::Context::New(NULL, m_global);
	m_context->Enter();

	init("window = new __internal_jwindow__");
}

} // end of namespace skins

} // end of 